rem windows开源编包入口

set CURRENTPATH=%~dp0
set AGENT_WORK_SPACE=%CURRENTPATH%..\..\
cd %AGENT_WORK_SPACE%\build\ms
set BINARY_PATH=%~1
set NO_PREPARE=%~2

if not "%NO_PREPARE%" == "no_prepare" (
    echo "======================= prepare start ========================"
    call agent_prepare.bat "%BINARY_PATH%"
    if %ERRORLEVEL% NEQ 0 (
        echo "Call agent_prepare.bat fail."
        call :Exit
        exit /b 1
    )
    echo "======================= prepare finish ========================"
)

call agent_make.bat compile64agent
if %ERRORLEVEL% NEQ 0 (
    echo "Call agent_make.bat fail."
    call :Exit
    call %AGENT_WORK_SPACE%build\ms\agent_make.bat Clean64Openssl
    exit /b 1
)
echo "======================= make finish ========================"

call agent_pack.bat
if %ERRORLEVEL% NEQ 0 (
    echo "Call agent_pack.bat fail."
    call :Exit
    exit /b 1
)

if not exist "%BINARY_PATH%\dependency\Windows" (
	md %BINARY_PATH%\dependency\Windows
)
COPY /Y %AGENT_WORK_SPACE%\build\ms\package\protectclient-Windows-x64.zip %BINARY_PATH%\dependency\Windows\
COPY /Y %AGENT_WORK_SPACE%\build\ms\package\plugin_sdk.zip %BINARY_PATH%\dependency\Windows\
echo "======================= pack finish ========================"
cd %CURRENTPATH%
exit /b 0

:Exit
    cd %CURRENTPATH%
    exit /b 1